import java.util.Random;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.By.ByName;

public class AddItem extends SeleniumBase {

	@Before
	public void setup() {

		open_www("http://demo.bananascrum.com/login");

		insertText(By.id("login"), "admin");
		insertText(By.id("password"), "password");
		click(By.name("commit"));
		Integer random = new Random().nextInt(10000000);

	}

	@Test
	public void AddItemTest() {
		Integer random = new Random().nextInt(10000000);

		click(By.className("backlog"));
		click(By.linkText("Add item"));
		insertText(By.id("item_user_story"), random.toString());
		insertText(By.id("item_description"), "Pawel 1,2,3,4,5");
		click(By.name("commit"));
		waitForElement(
				By.xpath("//div/div[2]/div[2]/div[2]/div[2]/div/div/div[6]/div[3]/ul/li/div[5]/div[2]"),
				random.toString());
		assertTextPresent(random.toString());
	}

}
